﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SubVersionOne
{
    public static class Logger
    {

        public async static void Info(string message, params object[] parameters)
        {
            string m = message;
            if (parameters != null && parameters.Any())
            {
                 m = String.Format(message, parameters);
            }
            await Write(m);
        }

        private static Task Write( string message)
        {
            return Task.Run(() =>
                {
                   FileInfo fi =new FileInfo(Constants.LogFile);
                    bool append =  fi.Length < 536870912 ? true : false;
                    using (StreamWriter sw = new StreamWriter(Constants.LogFile, append))
                    {
                        sw.WriteLine(message);
                    }
                });
        }
    }
}
